package com.aruba.attendance.util

import com.ctrip.flight.mmkv.MMKV_KMP
import java.text.SimpleDateFormat

/**
 * Created by aruba on 2023/2/15.
 */
object TimeUtil {
    const val FORMAT = "HH时mm分"

    fun hour2String(hour: Int): String {
        return if (hour < 10)
            "0${hour}时"
        else
            "${hour}时"
    }

    fun minute2String(minute: Int): String {
        return if (minute < 10)
            "0${minute}分"
        else
            "${minute}分"
    }

    fun calcDuration(startTime: String?, endTime: String?): Long {
        if (startTime == null || endTime == null) return 0
        
        return SimpleDateFormat(FORMAT).run {
            parse(endTime).time - parse(startTime).time
        }
    }
}